<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/taglib.jsp" %>
<html>
<head>
<link rel="stylesheet" href="${ctx}/static/css/lq.datetimepick.css">
<link rel="stylesheet" href="${ctx}/static/css/Master.css">
<script src="${ctx}/static/js/jquery-1.8.0.min.js"></script>
<script src="${ctx}/static/js/simpletooltip.min.js"></script>
<script src="${ctx}/static/js/selectUi.js"></script>
<script src="${ctx}/static/js/lq.datetimepick.js"></script>
<script type="text/javascript" src="${ctx}/static/js/jquery.validate.min.js"></script>
<link href="${ctx}/static/css/validation.css" type="text/css" rel="stylesheet"/>
<link rel="stylesheet" href="${ctx}/static/css/jquery-labelauty.css"/>
<script src="${ctx}/static/js/jquery-labelauty.js"></script>
<script type="text/javascript" src="${ctx}/static/js/jquery.metadata.js"></script>
<script src="${ctx}/static/plugins/layer/layer.js"></script>
<script type="text/javascript" src="${ctx}/static/js/messages_cn.js"></script>
<script src="${ctx}/static/plugins/My97DatePicker/WdatePicker.js"></script>
<%-- 基础js,所有页面都需要引入此js,依赖layer.js --%>
<script src="${ctx}/static/js/common/base.js"></script>
<script>
$(document).ready(function(){
    var setTypeDetail ="${advice.setTypeDetail}";
	if(setTypeDetail==12){
	  var checkId="${orgId}";
	  $("#platId").val(checkId);	
	}
	if(setTypeDetail==16){
		$("#platId").val(-1);
	}	

});

 
 
$(function(){
	   var form;
	   $("#form1").validate({
			   
	       rules:{
	    	      advTitle:{
	                   required:true,
	                   maxlength:20
	                   
	               },
	               advDetails:{
	                   required:true,
	                   maxlength:500
	               },
	               startDateNew:{
	            	  required:true
	               },
	               
	               platOrgId:{
	            	   platId:true
		               } 
	           }
	   
	    
		   });
	   
	   jQuery.validator.addMethod("platId",function(value,element){
		    //alert(value);
			if(value==-2)
			{return false;}
			 return true;
			},"请选择投放范围");
	 
	  
		   	    
	   });
	   
	    function formSubmit(){
		   var form=$("#form1");
		   if(!form.valid()){
			   return false;
		   }
		   
		   $.ajax({    
			    url:"${ctx}/announce/saveAnnounceEdit",
			    data:form.serialize(),    
			    type:"post",    
			    cache:false,    
			    dataType:"json",
			    async:true, //默认为true 异步    
			    success:function(data) {
			    	//alert(data);
			       // top.layer.msg(data,{},function(){
			        	  //alert("ssssssssssss");
			        	//window.location="${ctx}/announce/list";   
		            //});
			       
			       top.layer.alert(data,{},function()
			    		   {
			    	   window.location="${ctx}/announce/list";
			    		   });
			     }
			});
	 
	   }
</script>
</head>



<body>

			<section class="boxRight">
				<div class="OrgTit">编辑公告</div>
				<div class="context">
				
					<div class="add_firstmenu">
					<form action="" method="post" id="form1">
					  <input type="hidden" name="advId"  value="${advice.advId}">
						<dl>
							<dt>
								<span class="im">*</span>标题
							</dt>
							<dd>
								<input name="advTitle" type="text" class="w3" value="${advice.advTitle}"  style="width:370;height:35"/>
							</dd>
						</dl>
						<dl>
							<dt>
								<span class="im">*</span>内容
							</dt>
							<dd>
								<div class="textareaBox w2"  >
									<textarea name="advDetails">${advice.advDetails}</textarea>
								</div>
							</dd>
						</dl>
						<dl>
							<dt>
								时间
							</dt>
							<dd>
							<span class="date"><input name="startDateNew" type="text" placeholder="时间" id="datetimepicker" value="<fmt:formatDate value="${advice.startDate}" pattern="yyyy-MM-dd" />"style="width:115;height:35" class="Wdate" onclick="WdatePicker()"/></span>
							</dd>
						</dl>
						<dl>
							<dt>
								<span class="im">*</span>投放范围
						
						</dt>
						
					<dd>
				 <c:if test="${flg==2}">	
				  <select name="platOrgId" id="platId">
				    <option value="-2">请选择</option>
				    <option value="-1">全平台</option>
				    <c:forEach items="${platList}" var="org">
				    <option value="${org.orgId}">${org.orgName}</option>
				  </c:forEach>
				  </select>
				 </c:if>	
				 <c:if test="${flg==1}">
				  <input type="text" name="setType1"  value="${orgName}" readonly="true">
				   <input type="hidden" name="platOrgId"  value="${orgId}" readonly="true">
				  </c:if>
					</dd>
					
				</dl>
					</form>	
						<div class="combtn"><a href="javascript:void(0);" onclick="formSubmit()">保存</a><a href="javascript:void(0);" onclick="history.back();">返回</a></div>
					</div>
				</div>
			
		</section>
</body>
</html>